//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1995-1999  Microsoft Corporation

Module Name:

RilSimTkit.h

Abstract:


Notes:


--*/

/*
#------------------------------------------------------------------------------
#    Revision History
#    Date          	   Author         	     Activity ID     		     Activity Headline
#    2007-03-19    zuoxiaona   	     CEDB200047228       Submit STK CODE -RIL- lampson
#------------------------------------------------------------------------------
*/
#pragma once
#include <simtkit.h>

// Fifth Byte settings
#define SIMTKIT_TEXTPARSE_HELPINFO                0x80
#define SIMTKIT_TEXTPARSE_PRIORITY                0x01
#define SIMTKIT_TEXTPARSE_CLEAR                   0x80
#define SIMTKIT_TEXTPARSE_INPUT_KEYPADDIGITS      0x00
#define SIMTKIT_TEXTPARSE_INPUT_SMDEFAULTALPHABET 0x01
#define SIMTKIT_TEXTPARSE_INPUT_UCS2              0x03
#define SIMTKIT_TEXTPARSE_NOECHO                  0x04
#define SIMTKIT_TEXTPARSE_PACKEDRESPONSE          0x08
#define SIMTKIT_TEXTPARSE_YESNO                   0x04

#define SIMTKIT_TEXTPARSE_RESPONSE_OK             0
#define SIMTKIT_TEXTPARSE_RESPONSE_TERMINATE      1
#define SIMTKIT_TEXTPARSE_RESPONSE_HELP           2
#define SIMTKIT_TEXTPARSE_RESPONSE_BACK           3
#define SIMTKIT_TEXTPARSE_RESPONSE_NORESPONSE     4
#define SIMTKIT_TEXTPARSE_MAINMENU_HELP           1
#define SIMTKIT_TEXTPARSE_SETUPMENU_USER          1
#define SIMTKIT_TEXTPARSE_SETUPMENU_PROBLEM       3
#define SIMTKIT_TEXTPARSE_DISPLAYTEXT_CLEAR       2
#define SIMTKIT_TEXTPARSE_DISPLAYTEXT_BUSY        3
#define SIMTKIT_TEXTPARSE_DISPLAYTEXT_BACK        4
#define SIMTKIT_TEXTPARSE_DISPLAYTEXT_NORESPONSE  5
#define SIMTKIT_TEXTPARSE_PLAYTONE_NOTPLAYED      2
#define SIMTKIT_TEXTPARSE_PLAYTONE_NOTSUPPORTED   3
#define SIMTKIT_TEXTPARSE_IDLETEXT_PROBLEM        1
#define SIMTKIT_TEXTPARSE_SETUPCALL_REJECT        1
#define SIMTKIT_TEXTPARSE_EVENTLIST_ERROR         1
#define SIMTKIT_TEXTPARSE_SETUPMENU_HELP          2
#define SIMTKIT_TEXTPARSE_DF_RESPONSE_TERMINATE         0

#define SIMTKIT_TEXTPARSE_LAUNCHBROWSER_USERREJECTED     3
#define SIMTKIT_TEXTPARSE_LAUNCHBROWSER_NOCAUSE          4
#define SIMTKIT_TEXTPARSE_LAUNCHBROWSER_BROWSERUNAVAIL   6
#define SIMTKIT_TEXTPARSE_LAUNCHBROWSER_MOBILEINCAPABLE  9

#define SIMTKIT_TEXTPARSE_OPENCHANNEL_NOTACCEPTED 0
#define SIMTKIT_TEXTPARSE_OPENCHANNEL_REQUIRED    1

#define SIMTKIT_TEXTPARSE_SENDDTMF_NOTACCEPTED    0
#define SIMTKIT_TEXTPARSE_SENDDTMF_REQUIRED       1

#define SIMTKIT_TEXTPARSE_GETINKEY_DIGITS         0
#define SIMTKIT_TEXTPARSE_GETINKEY_PACKED         1
#define SIMTKIT_TEXTPARSE_GETINKEY_UCS            2
#define SIMTKIT_TEXTPARSE_GETINKEY_YESNO          3

#define SIMTKIT_TEXTPARSE_GETINPUT_DIGIT_UNPACKED 0
#define SIMTKIT_TEXTPARSE_GETINPUT_DIGIT_PACKED   1
#define SIMTKIT_TEXTPARSE_GETINPUT_DIGIT_UCS2     2
#define SIMTKIT_TEXTPARSE_GETINPUT_ALPHA_UNPACKED 3
#define SIMTKIT_TEXTPARSE_GETINPUT_ALPHA_PACKED   4
#define SIMTKIT_TEXTPARSE_GETINPUT_ALPHA_UCS2     5

#define SIMTKIT_TEXTPARSE_SIMREFRESH_SIMINIT_FULL 0
#define SIMTKIT_TEXTPARSE_SIMREFRESH_FILE         1
#define SIMTKIT_TEXTPARSE_SIMREFRESH_SIMINIT_FILE 2
#define SIMTKIT_TEXTPARSE_SIMREFRESH_SIMINIT      3
#define SIMTKIT_TEXTPARSE_SIMREFRESH_RESET        4

#define SIMTKIT_TEXTPARSE_PARSE_LEADINGZERO       true
#define SIMTKIT_TEXTPARSE_PARSE_NOLEADINGZERO     false

// Leading encoding byte for EF ADN encoded text.
#define SIMTKIT_TEXTPARSE_ALPHAID_UCS2            (0x80)
#define SIMTKIT_TEXTPARSE_ALPHAID_MIXED_8BIT      (0x81)
#define SIMTKIT_TEXTPARSE_ALPHAID_MIXED_16BIT     (0x82)

#define SIMTKIT_TEXT_ENCODING_ALPHAID             (0x8000)

// TLV tag values
#define COMMANDIDTAG         0x01
#define DEVICEIDTAG          0x02
#define RESULTTAG            0x03
#define DURATIONTAG          0x04
#define ALPHAIDTAG           0x05
#define ADDRESSTAG           0x06
#define CAPABILITYTAG        0x07
#define SUBADDRTAG           0x08
#define SSSTRINGTAG          0x09
#define USSDSTRINGTAG        0x0A
#define TPDUTAG              0x0B
// 0x0C is Cell Broadcast page tag
#define TEXTTAG              0x0D
#define TONETAG              0x0E
#define MENUITEMTAG          0x0F
#define ITEMIDTAG            0x10
#define RESPONSETAG          0x11
#define FILELISTTAG          0x12
#define LOCINFOTAG           0x13
#define IMEITAG              0x14
#define HELPTAG              0x15
#define NMRTAG               0x16
#define DEFTEXTTAG           0x17
#define NEXTACTIONTAG        0x18
#define EVENTLISTTAG         0x19
#define ICONTAG              0x1E
#define ICONLISTTAG          0x1F
#define ATCMDTAG             0x28
#define IMMEDIATETAG         0x2B
#define DTMFTAG              0x2C
#define LANGUAGETAG          0x2D
#define BROWSERIDTAG         0x30
#define URLTAG               0x31
#define BEARERTAG            0x32
#define PROVISIONFILETAG     0x33
#define BEARERDESCRIPTTAG    0x35
#define CHANNELDATATAG       0x36
#define CHANNELDATALENTAG    0x37
#define BUFFERSIZETAG        0x39
#define TRANSPORTLVLTAG      0x3C
#define OTHERADDRTAG         0x3E
#define NETACCESSNAMETAG     0x47

#define BCCHTAG              0x1D
#define MENUSELECTTAG        0xD3
#define EVENTDOWNLOADTAG     0xD6
#define OPTIONALTAG          0x80000000

#define COMMANDLENGTH        5
#define MAX_BYTE_RSP         255
#define MAX_TEXT_RSP         512
#define SIMTKIT_TEXTPARSE_EMPTY_STRING L"\0"
#define SIMTKIT_TEXTPARSE_YES          L"01"
#define SIMTKIT_TEXTPARSE_NO           L"00"
#define SIMTKIT_INVALID_VALUE          (0xFFFFFFFF)

#define SIMTK_OPENCHANNEL_CS    ADDRESSTAG
#define SIMTK_OPENCHANNEL_GPRS  BEARERDESCRIPTTAG

// Default Terminal Profile constants
#define MAX_TERMINAL_PROFILE                      (32)
#define DEF_TERMINAL_PROFILE_SIZE                 (9)
static const BYTE gsc_pbDefTerminalProfile[]    = {0x01, 0x61, 0xFF, 0x7F, 0x61, 0x00, 0x00, 0x30, 0x21};
static const TCHAR* gsc_szTerminalProfileRegKey = TEXT("TerminalProfile");

#define ROUNDTODWORD(p)             (DWORD) (4 * (((DWORD) p + 3) / 4))


BOOL ParseBytes(const LPBYTE pbData, LPBYTE& rpbData, size_t& rcbData, LPBYTE& rpbPointer);
BOOL ParseEncodedText(const LPBYTE pbData, DWORD dwEncoding, LPWSTR& rwszOut, size_t& rcbOut, LPBYTE& rpbPointer);
BOOL CreateEncodedText(DWORD dwEncoding, const LPWSTR wszIn, LPSTR& rszOut, UINT& ruiOutSize);
BOOL ConvertAlphaIDTextToUnicode(const LPCSTR szInput, const UINT uiInputLength, const LPWSTR wszOutput, const UINT uiOutputLength, UINT& ruiCharactersUsed);


class CRilSimToolkitCommand
{
public:
    // Creation
    CRilSimToolkitCommand();
    ~CRilSimToolkitCommand();

    // Parsing commands
    DWORD ParseCommand(LPCSTR szData, DWORD dwDataSize, RILSIMTOOLKITCMD **ppCommand, DWORD *pdwCommandSize);

private:

    // Common reading functions
    HRESULT ReadCmdLength(DWORD *pdwLength);
    HRESULT ReadCommonTextString(TCHAR **ppwszText, DWORD *pdwLen);
    HRESULT ReadDialNumberString(TCHAR **ppwsz, DWORD *pdwLen);
    HRESULT ReadEFADNText(TCHAR **ppwszText, DWORD dwLength, DWORD *pdwUsedLen);
    HRESULT ReadCommonEFADNText(TCHAR **ppwszText, DWORD *pdwLen);
    HRESULT ReadCommonByte(DWORD *pdwData);
    HRESULT ReadCommonByteList(BYTE **ppbData, DWORD *pdwLen);
    HRESULT ReadCommonByteAndByteList(DWORD* pdwByte, BYTE **ppbData, DWORD *pdwLen);
    HRESULT ReadCommonIconIdentifier(LPDWORD pdwIconIdentifier, LPDWORD pdwIconQualifier);

    // Text Format Parse command Functions
    HRESULT ParseTextFormatCommand(DWORD* pdwNotifyCode, BYTE* pbFifthByte, DWORD* pdwRetVal);
    HRESULT ParseSetupMenu(DWORD dwCommandID, BYTE* pbFifthByte);
    HRESULT ParseMenuItem(LPBYTE& rpbParse);
    HRESULT ParseDisplayText(BYTE* pbFifthByte);
    HRESULT ParseGetInKey(BYTE* pbFifthByte);
    HRESULT ParseGetInput(BYTE* pbFifthByte);
    HRESULT ParsePlayTone(void);
    HRESULT ParseSetupIdleModeText(void);
    HRESULT ParseUnsolicitedData(void);
    HRESULT ParseRefresh(BYTE* pbFifthByte);
    HRESULT ParseEventList(void);
    HRESULT ParseLaunchBrowser(BYTE* pbFifthByte);
    HRESULT ParseProvisionFile(LPBYTE& rpbParse);
    HRESULT ParseReceiveData(void);
    HRESULT ParseSendData(void);
    HRESULT ParseLanguageNotification(void);

   // Dragonfly Text Format Parse command Functions
    HRESULT ParseDFTextFormatCommand(DWORD* pdwNotifyCode, BYTE* pbFifthByte, DWORD* pdwRetVal);
    HRESULT ParseDFSetupMenu(DWORD dwCommandID, BYTE* pbFifthByte);
    HRESULT ParseDFMenuItem(LPBYTE& rpbParse,BYTE* pbFifthByte);
    HRESULT ParseDFDisplayText(BYTE* pbFifthByte);
    HRESULT ParseDFGetInput(BYTE* pbFifthByte);
    HRESULT ParseDFSetupCall(BYTE* pbFifthByte);
    HRESULT ParseDFUnsolicitedData(void);
    HRESULT ParseDFRefresh(BYTE* pbFifthByte);
    // Functions to read each TLV
    HRESULT ReadDuration();
    HRESULT ReadMenuItem();
    HRESULT ReadNextAction();
    HRESULT ReadItemIdentifier();
    HRESULT ReadResponseLength();
    HRESULT ReadSubAddress();
    HRESULT ReadCapability();
    HRESULT ReadFileList();
    HRESULT ReadProvisionFileList();
    HRESULT ReadBufferSize();
    HRESULT ReadTransportLevel();
    HRESULT ReadIconIdentifierList();
    HRESULT ReadImmediate();
    HRESULT ReadDTMF();

    HRESULT ReadTone() { ASSERT(m_dwTone == SIMTONE_DEFAULT); return ReadCommonByte(&m_dwTone); }
    HRESULT ReadBrowserIdentity() { return ReadCommonByte(&m_dwBrowserId); }
    HRESULT ReadChannelDataLength() { return ReadCommonByte(&m_dwChannelDataLength); }
    HRESULT ReadTPDU()  { return ReadCommonByteList(&m_lpbTPDU, &m_dwTPDULen); }
    HRESULT ReadEventList()  { return ReadCommonByteList(&m_lpbEventList, &m_dwEventListLen); }
    HRESULT ReadBearer() { return ReadCommonByteList(&m_lpbBearer, &m_dwBearerLen); }
    HRESULT ReadChannelData() { return ReadCommonByteList(&m_lpbChannelData, &m_dwChannelDataLen); }
    HRESULT ReadBearerDescription() { return ReadCommonByteAndByteList( &m_dwBearerDescType, &m_lpbBearerDesc, &m_dwBearerDescLen); }
    HRESULT ReadAddress() { return ReadDialNumberString(&m_pwszAddress, &m_dwAddressLen); }
    HRESULT ReadShortString() { return ReadDialNumberString(&m_pwszUSSD, &m_dwUSSDLen); }
    HRESULT ReadTextString() { return ReadCommonTextString(&m_pwszText, &m_dwTextLen); }
    HRESULT ReadDefaultTextString() { return ReadCommonTextString(&m_pwszDefaultText, &m_dwDefaultTextLen); }
    HRESULT ReadUSSD() { return ReadCommonTextString(&m_pwszUSSD, &m_dwUSSDLen); }
    HRESULT ReadLanguage() { return ReadCommonEFADNText(&m_pwszLanguage, &m_dwLanguageLen); }
    HRESULT ReadAlphaIdentifier() { return ReadCommonEFADNText(&m_pwszAlphaId, &m_dwAlphaIdLen); }
    HRESULT ReadURL() { return ReadCommonEFADNText(&m_pwszURL, &m_dwURLLen); }
    HRESULT ReadATCommand() { return ReadCommonEFADNText(&m_pwszText, &m_dwTextLen); }
    HRESULT ReadAlphaIdentifier2() { return ReadCommonEFADNText(&m_pwszAlphaId2, &m_dwAlphaId2Len); }
    HRESULT ReadIconIdentifier() { return ReadCommonIconIdentifier(&m_dwIconIdentifier, &m_dwIconQualifier); }
    HRESULT ReadIconIdentifier2() { return ReadCommonIconIdentifier(&m_dwIconIdentifier2, &m_dwIconQualifier2); }

    // Once we've parsed, we need to build up our structures
    HRESULT BuildSIMPOLLINGINTERVAL(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMLOCALINFO(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMCALL(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMTONE(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMTEXT(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMMENU(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMREFRESH(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMUSSD(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMSMS(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMEVENTLIST(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMLAUNCHBROWSER(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMSENDDTMF(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMOPENCHANNEL(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMCLOSECHANNEL(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMSENDDATA(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMRECEIVEDATA(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMLANGUAGE(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);
    HRESULT BuildSIMRUNATCMD(DWORD dwNotifyCode, BYTE bFifthByte, LPBYTE *ppbResult, DWORD *lpdwSize);

    // Functions to parse Open Channel byte commands
    HRESULT ByteParseOpenChannelCS(DWORD* pdwRetVal);
    HRESULT ByteParseOpenChannelGPRS(DWORD* pdwRetVal);

    // Members
    WORD m_fTextNotifications:1;

    // Variables for parsing a command
    LPBYTE m_lpbParse;
    DWORD m_dwParseLen;

    TCHAR *m_pwszAlphaId;
    DWORD m_dwAlphaIdLen;
    TCHAR *m_pwszText;
    DWORD m_dwTextLen;
    TCHAR *m_pwszDefaultText;
    DWORD m_dwDefaultTextLen;
    TCHAR *m_pwszAddress;
    DWORD m_dwAddressLen;
    TCHAR *m_pwszSubAddr;
    DWORD m_dwSubAddrLen;
    TCHAR *m_pwszUSSD;
    DWORD m_dwUSSDLen;
    BYTE *m_lpbTPDU;
    BYTE *m_lpbEventList;
    DWORD *m_pdwFiles;
    DWORD m_dwTPDULen;
    DWORD m_dwEventListLen;
    DWORD m_dwNumFiles;
    DWORD m_dwDuration;
    DWORD m_dwDuration2;
    DWORD m_dwTone;
    DWORD m_dwMinResponse;
    DWORD m_dwMaxResponse;
    DWORD m_dwItemId;
    LPSIMMENUITEM *m_rgpsmi;
    DWORD m_numpsmi;
    DWORD m_dwNumPlan;
    DWORD m_dwAddrType;
    DWORD m_dwBrowserId;
    TCHAR *m_pwszURL;
    DWORD m_dwURLLen;
    BYTE *m_lpbBearer;
    DWORD m_dwBearerLen;
    LPSIMFILEREFERENCE *m_rgpsfr;
    DWORD m_numpsfr;
    TCHAR *m_pwszDTMF;
    DWORD m_dwDTMFLen;
    BYTE *m_lpbChannelData;
    DWORD m_dwChannelDataLen;
    DWORD m_dwChannelDataLength;
    DWORD m_dwDeviceSrcId;
    DWORD m_dwDeviceDestId;
    TCHAR *m_pwszLanguage;
    DWORD m_dwLanguageLen;
    DWORD m_dwLocalAddrType;
    BYTE* m_lpbLocalAddr;
    DWORD m_dwLocalAddrLen;
    DWORD m_dwDestAddrType;
    BYTE* m_lpbDestAddr;
    DWORD m_dwDestAddrLen;
    TCHAR* m_pwszLogin;
    DWORD m_dwLoginLen;
    TCHAR* m_pwszPassword;
    DWORD m_dwPasswordLen;
    DWORD m_dwBearerDescType;
    BYTE* m_lpbBearerDesc;
    DWORD m_dwBearerDescLen;
    DWORD m_dwBufferSize;
    DWORD m_dwProtocolType;
    DWORD m_dwPortNum;
    BYTE* m_lpbAccessName;
    DWORD m_dwAccessNameLen;
    BOOL  m_fImmediateResponse;
    DWORD m_dwIconIdentifier;
    DWORD m_dwIconQualifier;
    TCHAR *m_pwszAlphaId2;
    DWORD m_dwAlphaId2Len;
    DWORD m_dwIconIdentifier2;
    DWORD m_dwIconQualifier2;
};


class CRilSimToolkitResponse
{
public:
    CRilSimToolkitResponse();
    ~CRilSimToolkitResponse();

    HRESULT CreateResponse(const RILSIMTOOLKITRSP* pRsp, LPBYTE pDetails, const DWORD dwDetailSize, LPSTR* pszDataRsp, DWORD *pdwDataRspSize );
    HRESULT CreateEventDownload(const DWORD dwEvent, const LPBYTE pData, const DWORD dwDataSize, LPSTR* szDataRsp, DWORD *pdwDataRspSize);

private:
    // Byte style responses
    HRESULT ByteFormatResponse(const RILSIMTOOLKITRSP* pRsp, const LPBYTE pDetails, const DWORD dwDetailSize, LPBYTE pbDataRsp, DWORD *pdwDataRspSize);
    HRESULT ByteEventDownload(const DWORD dwEvent, const LPBYTE pData, const DWORD dwDataSize, LPBYTE pbDataRsp, DWORD *pdwDataRspSize);
    // Text style responses
    HRESULT TextFormatResponse(const RILSIMTOOLKITRSP* pRsp, const LPBYTE pDetails, const DWORD dwDetailSize, LPBYTE pbDataRsp, DWORD *pdwDataRspSize);
    HRESULT TextEventDownload(const DWORD dwEvent, const LPBYTE pData, const DWORD dwDataSize, LPSTR szDataRsp, DWORD *pdwDataRspSize);
    HRESULT SetupMenuResponse(DWORD dwResponse, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT SetupMenuReply(DWORD dwResponse, const LPBYTE pDetails, const DWORD dwDetailSize, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT SelectItemResponse(DWORD dwResponse, const LPBYTE pDetails, const DWORD dwDetailSize, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT DisplayTextResponse(DWORD dwResponse, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT GetInputResponse(const RILSIMTOOLKITRSP* pRsp, const LPBYTE pDetails, const DWORD dwDetailSize, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT PlayToneResponse(DWORD dwResponse, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT SetupIdleModeTextResponse(DWORD dwResponse, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT SetupCallResponse(DWORD dwResponse, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT EventListResponse(DWORD dwResponse, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT LaunchBrowserResponse(const RILSIMTOOLKITRSP* pRsp, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT OpenChannelResponse(DWORD dwResponse, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT SendDTMFResponse(DWORD dwResponse, BYTE* pbBuffer, DWORD* pdwSize);

    // Text style responses for Philips
    HRESULT TextFormatDFResponse(const RILSIMTOOLKITRSP* pRsp, const LPBYTE pDetails, const DWORD dwDetailSize, LPBYTE pbDataRsp, DWORD *pdwDataRspSize);
    HRESULT SetupMenuDFReply(DWORD dwResponse, const LPBYTE pDetails, const DWORD dwDetailSize, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT SetupMenuDFResponse(DWORD dwResponse, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT SelectItemDFResponse(DWORD dwResponse, const LPBYTE pDetails, const DWORD dwDetailSize, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT DisplayTextDFResponse(DWORD dwResponse, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT GetInputDFResponse(const RILSIMTOOLKITRSP* pRsp, const LPBYTE pDetails, const DWORD dwDetailSize, BYTE* pbBuffer, DWORD* pdwSize);
    HRESULT SetupCallDFResponse(DWORD dwResponse, BYTE* pbBuffer, DWORD* pdwSize);
    BOOL m_fTextFormat;
};


class CRilSTKTerminalProfile
{
public:
    CRilSTKTerminalProfile();
    ~CRilSTKTerminalProfile();

    BOOL InitializeDefault(void);
    LPCSTR GetText(void);
    BOOL SetByte(const LPBYTE pbValue, const DWORD dwSize);
    const LPBYTE GetByte(void);
    DWORD GetSize(void);

private:
    LPSTR m_szProfileText;      // Stores ANSI text version of terminal profile
    BYTE* m_pbProfile;          // Byte buffer of terminal profile
    DWORD m_dwProfileSize;      // Size in bytes of terminal profile

    BOOL SetTerminalProfile(const LPBYTE pbValue, const DWORD dwSize);
    BOOL SetDefaultTerminalProfile(void);
};

